from flask import Flask
from celery import Celery
import celeryconfig

app = Flask(__name__)
celery_app = Celery(app.import_name,
                    broker=celeryconfig.broker_url,
                    backend=celeryconfig.result_backend)
celery_app.config_from_object(celeryconfig)


@celery_app.task(name='simple/add2')
def add2(x, y):
    return x + y


@app.route('/')
def index():
    results = add2.delay(3, 5)
    return str(results.wait())


if __name__ == '__main__':
    app.run(debug=True)